home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC-SIG: World of Games
/
PC-SIG World of Games (CDRM1080710) (1993).iso
/
55
/
CRAZY8.BAS
< prev
next >
Wrap
BASIC Source File
|
1983-02-27
|
9KB
|
296 lines
10 REM Author Les Davids
20 DIM SUIT$(4),CARD$(52),DECK$(52)
30 DIM FIG$(5,5)
40 DEFINT A-Z
50 DIM DECK(52),PHAND$(26),CHAND$(26)
60 DIM TEST(52),OLDHAND$(25)
70 SCREEN 0,1:COLOR 0,7,7:CLS
80 KEY OFF
90 LOCATE 2,9
100 PRINT "C R A Z Y E I G H T S"
110 DIM VALUE$(13),VALUE(13)
120 LOCATE 4,1
130 PRINT"The objective of the game is to get rid"
140 PRINT"of all your cards by placing them on"
150 PRINT"the discard pile."
160 PRINT"You can play a card if you have the "
170 PRINT"same suit, the same number (in which"
180 PRINT"case the suit changes), or at any time"
190 PRINT"you can play an eight. If you play an"
200 PRINT"eight you will be prompted for new suit (h,c,s,d)."
210 PRINT"If you cannot go, hit the space bar."
220 PRINT"You will then be dealt a new card."
230 PRINT
240 PRINT"Game will end at 100 points."
250 PRINT"The winner receives points from the"
260 PRINT"losers hand. Points are equal to "
270 PRINT"face value. Face cards are 10 each,"
280 PRINT"aces are worth 15."
290 LOCATE 22,15:INPUT "NAME ",N$
300 CLS: LOCATE 2,9
310 DATA "A","2","3","4","5","6","7"
320 DATA "8","9","0","J","Q","K"
330 DATA 15,2,3,4,5,6,7,8,9,10,10,10,10
340 FOR I=1 TO 13:READ VALUE$(I):NEXT I
350 FOR I=1 TO 13:READ VALUE(I):NEXT I
360 PRINT "C R A Z Y E I G H T S"
370 LOCATE 5,2:PRINT"SCORE"
380 LOCATE 6,4:PRINT "COMPUTER";CSCORE
390 LOCATE 7,4:PRINT N$;PSCORE
400 FOR I=1 TO 40
410 LOCATE 9,I: PRINT CHR$(205)
420 NEXT I
430 REM ** shuffle cards
440 GOSUB 1510
450 REM ** deal cards
460 COLOR 7,7
470 FOR I = 1 TO 8
480 J=1+((I-1)*2)
490 PHAND$(I)=DECK$(J)
500 CHAND$(I)=DECK$(J+1)
510 NEXT I
520 NEXTCARD = 18
530 UPCARD$ = DECK$(17)
540 PCARDS=8
550 CCARDS=8
560 REM ** sort player's hand
570 SORTTEST=1
580 WHILE SORTTEST
590 SORTTEST=0
600 FOR I=1 TO PCARDS-1
610 CHAR1$=MID$(PHAND$(I),3)
620 CHAR2$=MID$(PHAND$(I+1),3)
630 IF CHAR1$>CHAR2$ THEN SWAP PHAND$(I),PHAND$(I+1) : SORTTEST = 1
640 NEXT I
650 WEND
660 THE$=" ": GOSUB 2380
670 THE$=UPCARD$: GOSUB 2470
680 ROW=4:COL=19:GOSUB 2390
690 ROW=10
700 FOR I=1 TO 6
710 IF I>(PCARDS+1) THEN 760
720 IF PHAND$(I)=OLDHAND$(I) THEN 780
730 OLDHAND$(I)=PHAND$(I)
740 THE$=PHAND$(I): GOSUB 2470
750 COL=1+(6*(I-1)): GOSUB 2390
760 LOCATE 15,(2+((I-1)*6))
770 IF I<=PCARDS THEN PRINT I ELSE PRINT " "
780 NEXT I
790 ROW=17
800 FOR I=7 TO (PCARDS+1)
810 J=I-6
820 IF PHAND$(I)=OLDHAND$(I) THEN 960
830 OLDHAND$(I)=PHAND$(I)
840 THE$=PHAND$(I): GOSUB 2470
850 COL=1+(6*(J-1)): GOSUB 2390
860 LOCATE 22,(2+((I-7)*6))
870 IF I=(PCARDS+1) THEN PRINT " ": GOTO 960
880 IF I<10 THEN PRINT I
890 IF I = 10 THEN PRINT " A"
900 IF I = 11 THEN PRINT " B"
910 IF I = 12 THEN PRINT " C"
920 IF I = 13 THEN PRINT " D"
930 IF I = 14 THEN PRINT " E"
940 IF I = 15 THEN PRINT " F"
950 IF I = 16 THEN PRINT " G"
960 NEXT I
970 LOCATE 23,20:PRINT"ENTER YOUR PLAY"
980 IN$=INKEY$:IF IN$="" THEN 980
990 LOCATE 7,29:PRINT" "
1000 LOCATE 23,20:PRINT"THINKING "
1010 IF IN$<>" " THEN 1090
1020 IF TAKE=1 THEN 1430
1030 PCARDS=PCARDS+1
1040 IF NEXTCARD = 53 THEN 2870
1050 PHAND$(PCARDS)=DECK$(NEXTCARD)
1060 NEXTCARD=NEXTCARD+1
1070 TAKE = 1
1080 GOTO 570
1090 IF IN$>"9" THEN 1120
1100 IN=VAL(IN$)
1110 GOTO 1220
1120 IF IN$="a" THEN IN=10
1130 IF IN$="b" THEN IN=11
1140 IF IN$="c" THEN IN=12
1150 IF IN$="d" THEN IN=13
1160 IF IN$="e" THEN IN=14
1170 IF IN$="e" THEN IN=15
1180 IF IN$<"a" OR IN$>"e" THEN 1190 ELSE 1220
1190 LOCATE 23,20
1200 PLAY "mfo1fd":PRINT "WRONG CARD"
1210 GOTO 970
1220 IN$=PHAND$(IN)
1230 IF MID$(IN$,2,1)="8" THEN 1290
1240 IF MID$(IN$,1,2) = MID$(UPCARD$,1,2) THEN 1380
1250 IF MID$(IN$,3,1) = MID$(UPCARD$,3,1) THEN 1380
1260 LOCATE 23,20
1270 PRINT "WRONG CARD"
1280 GOTO 970
1290 LOCATE 23,20: PRINT"WHAT SUIT?"
1300 S$=INKEY$: IF S$="" THEN 1300
1310 IF S$ = "c" THEN 1360
1320 IF S$ = "d" THEN 1360
1330 IF S$ = "h" THEN 1360
1340 IF S$ = "s" THEN 1360
1350 GOTO 1300
1360 REM ** switch suit
1370 MID$(IN$,3,1)=MID$(S$,1,1)
1380 TAKE = 0
1390 UPCARD$ = IN$
1400 IF IN = PCARDS THEN 1420
1410 PHAND$(IN) = PHAND$(PCARDS)
1420 PCARDS = PCARDS - 1
1430 PHAND$(PCARDS+1) = " "
1440 IF PCARDS=0 THEN 2750
1450 TAKE=0
1460 GOSUB 1870
1470 IF CCARDS = 0 THEN 2750
1480 TAKE=0
1490 GOTO 560
1500 END
1510 REM ******* shuffle routine ******
1520 LOCATE 6,29: PRINT"NEW GAME"
1530 TIM$=MID$(TIME$,4,2)
1540 TIM$=TIM$+MID$(TIME$,7,2)
1550 SEED=VAL(TIM$)
1560 RANDOMIZE(SEED)
1570 COUNT = 1
1580 WHILE COUNT < 53
1590 NUMBR=100*RND
1600 IF NUMBR > 52 THEN 1590
1610 IF NUMBR = 0 THEN 1590
1620 IF TEST(NUMBR) = 1 THEN 1590
1630 TEST(NUMBR) = 1
1640 DECK(COUNT) = NUMBR
1650 COUNT = COUNT + 1
1660 WEND
1670 IF PSCORE <>0 OR CSCORE<>0 THEN 1820
1680 DATA "c","d","h","s"
1690 FOR I=1 TO 4
1700 READ SUIT$(I)
1710 NEXT I
1720 DATA " A"," 2"," 3"," 4"," 5"," 6"," 7"
1730 DATA " 8"," 9","10"," J"," Q"," K"
1740 FOR I = 1 TO 4
1750 FOR J = 1 TO 13
1760 N = J+((I-1)*13)
1770 READ CARD$(N)
1780 CARD$(N)=CARD$(N)+SUIT$(I)
1790 NEXT J
1800 RESTORE 1720
1810 NEXT I
1820 FOR I=1 TO 52
1830 DECK$(I) = CARD$(DECK(I))
1840 PLAY "mbl64t255o0aa-p64"
1850 NEXT I
1860 RETURN
1870 REM ** computer section
1880 REM ** sort computer's hand
1890 TAKE=0
1900 SORTTEST=1
1910 WHILE SORTTEST
1920 SORTTEST=0
1930 FOR I=1 TO CCARDS-1
1940 CHAR1$=MID$(CHAND$(I),3)
1950 CHAR2$=MID$(CHAND$(I+1),3)
1960 IF CHAR1$>CHAR2$ THEN SWAP CHAND$(I),CHAND$(I+1) : SORTTEST = 1
1970 NEXT I
1980 WEND
1990 REM ** look for suit
2000 FOR IN=1 TO CCARDS
2010 S$=MID$(UPCARD$,3,1)
2020 T$=MID$(CHAND$(IN),3,1)
2030 IF S$=T$ AND MID$(CHAND$(IN),2,1)<>"8" THEN 2330
2040 NEXT IN
2050 REM ** look for number
2060 FOR IN=1 TO CCARDS
2070 S$=MID$(UPCARD$,1,2)
2080 T$=MID$(CHAND$(IN),1,2)
2090 IF S$=T$ THEN 2330
2100 NEXT IN
2110 REM ** look for eight
2120 FOR IN = 1 TO CCARDS
2130 IF MID$(CHAND$(IN),2,1)="8" THEN 2250
2140 NEXT IN
2150 REM ** take another card
2160 IF TAKE = 1 THEN TAKE=0: RETURN
2170 TAKE = 1
2180 CCARDS=CCARDS+1
2190 CHAND$(CCARDS)=DECK$(NEXTCARD)
2200 NEXTCARD=NEXTCARD+1
2210 LOCATE 6,29:PRINT "CARDS ";CCARDS
2220 LOCATE 7,29: PRINT"TOOK CARD"
2230 IF NEXTCARD = 53 THEN 2870
2240 GOTO 1900
2250 REM ** space for playing 8
2260 IF IN = 1 THEN S$=MID$(CHAND$(2),3,1) ELSE S$=MID$(CHAND$(1),3,1)
2270 MID$(CHAND$(IN),3,1)=S$
2280 LOCATE 7,29
2290 IF S$="c" THEN PRINT"CLUBS "
2300 IF S$="d" THEN PRINT"DIAMONDS "
2310 IF S$="h" THEN PRINT"HEARTS "
2320 IF S$="s" THEN PRINT"SPADES "
2330 UPCARD$=CHAND$(IN)
2340 IF IN <> CCARDS THEN CHAND$(IN)=CHAND$(CCARDS)
2350 CCARDS=CCARDS-1
2360 LOCATE 6,29:PRINT "CARDS ";CCARDS
2370 IF CCARDS=1 THEN LOCATE 7,29: PRINT"LAST CARD":SOUND 400,5
2380 RETURN
2390 REM ** print a card
2400 FOR SI=1 TO 5
2410 FOR SJ = 1 TO 5
2420 LOCATE (ROW+(SI-1)),(COL+(SJ-1))
2430 PRINT FIG$(SI,SJ)
2440 NEXT SJ,SI
2450 COLOR 2,7
2460 RETURN
2470 REM ** create figure
2480 IF PASS = 1 THEN 2640
2490 PASS=1
2500 FIG$(2,4)=" "
2510 FIG$(3,4)=" "
2520 FIG$(3,2)=" "
2530 FIG$(4,2)=" "
2540 FIG$(1,1)=CHR$(201)
2550 FIG$(1,5)=CHR$(187)
2560 FIG$(5,1)=CHR$(200)
2570 FIG$(5,5)=CHR$(188)
2580 FOR SI=1 TO 3
2590 FIG$(1,SI+1)=CHR$(205)
2600 FIG$(5,SI+1)=CHR$(205)
2610 FIG$(SI+1,1)=CHR$(186)
2620 FIG$(SI+1,5)=CHR$(186)
2630 NEXT SI
2640 IF THE$=" " THEN FOR SI=1 TO 5 : FOR SJ=1 TO 5:COLOR 7,7: FIG$(SI,SJ) = " ": NEXT SJ,SI: PASS=0: RETURN
2650 COLOR 7,2:FIG$(2,3)=" "
2660 FIG$(4,3)=" "
2670 IF MID$(THE$,1,1)=" " THEN FIG$(2,2)=MID$(THE$,2,1): FIG$(4,4)=FIG$(2,2) ELSE FIG$(2,2)="1":FIG$(2,3)="0": FIG$(4,3)="1":FIG$(4,4)="0"
2680 S$=MID$(THE$,3,1)
2690 IF S$="d" THEN FIG$(3,3)=CHR$(4):COLOR 4,7
2700 IF S$="c" THEN FIG$(3,3)=CHR$(5):COLOR 0,7
2710 IF S$="h" THEN FIG$(3,3)=CHR$(3):COLOR 4,7
2720 IF S$="s" THEN FIG$(3,3)=CHR$(6):COLOR 0,7
2730 RETURN
2740 END
2750 LOCATE 7,29
2760 IF PCARDS=0 THEN PRINT"YOU WIN!!" ELSE PRINT"I WIN !!"
2770 FOR SI=1 TO PCARDS
2780 SPHAND$=SPHAND$+PHAND$(SI)
2790 FOR SJ=1 TO 13
2800 IF MID$(PHAND$(SI),2,1)=MID$(VALUE$(SJ),1,1) THEN CSCORE=CSCORE+VALUE(SJ)
2810 NEXT SJ,SI
2820 FOR SI=1 TO CCARDS
2830 SCHAND$=SCHAND$+CHAND$(SI)
2840 FOR SJ=1 TO 13
2850 IF MID$(CHAND$(SI),2,1)=MID$(VALUE$(SJ),1,1) THEN PSCORE=PSCORE+VALUE(SJ)
2860 NEXT SJ,SI
2870 FOR SI=1 TO 52
2880 TEST(SI)=0
2890 NEXT SI
2900 IF PSCORE<100 AND CSCORE <100 THEN 370
2910 LOCATE 6,4:PRINT "COMPUTER";CSCORE
2920 LOCATE 7,4:PRINT N$;PSCORE
2930 PRINT"thank you"
2940 END
65399 '** DONE - PRESS ENTER TO RETURN TO MENU **